package com.ebt.m.customer.util;

import com.ebt.m.customer.model.CustomerModel;
import com.ebt.m.customer.model.CustomerModelDetail;
import com.ebt.m.customer.model.CustomerModelMulti;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Rick.Wang on 2016/4/14.
 */
public class CustomerMergeDetailGeneral {

    public static void inflateCustomerModelMultis(List<CustomerModelMulti> customerModelMultisOutput,
                                                  List<CustomerModelDetail> customerModelDetails,
                                                  List<CustomerModel> customerModelGenerals){
        if(customerModelMultisOutput == null){
            customerModelMultisOutput = new ArrayList();
        }
        boolean flagModelDetail = false;
        if(customerModelDetails != null && customerModelDetails.size() > 0){
            flagModelDetail = true;
            for(CustomerModelDetail item : customerModelDetails){
                customerModelMultisOutput.add(new CustomerModelMulti(CustomerModelMulti.TYPE_ITEM_0_DETAIL, item));
            }
        }
        if(flagModelDetail) {
            customerModelMultisOutput.add(0, new CustomerModelMulti(CustomerModelMulti.TYPE_ITEM_1_DIVIDER,
                "活动客户(" + customerModelDetails.size() + ")"));
    }

        boolean flagModelGeneral = false;
        if(customerModelGenerals != null && customerModelGenerals.size() > 0){
            flagModelGeneral = true;
            for(CustomerModel item : customerModelGenerals){
                customerModelMultisOutput.add(new CustomerModelMulti(CustomerModelMulti.TYPE_ITEM_2_GENERAL, item));
            }
        }

        if(flagModelGeneral) {
            customerModelMultisOutput.add((flagModelDetail ? customerModelDetails.size() + 1 : 0), new CustomerModelMulti(CustomerModelMulti.TYPE_ITEM_1_DIVIDER,
                    "全部客户(" + customerModelGenerals.size() + ")"));
        }
    }
}
